package ru.unlocker.reports.sampler.service;

import static org.junit.jupiter.api.Assertions.*;

import java.io.File;
import java.io.IOException;
import java.time.Duration;
import java.util.List;
import java.util.UUID;
import org.junit.jupiter.api.Test;
import ru.unlocker.reports.domain.ReportEventKind;
import ru.unlocker.reports.domain.TimerEventKind;
import ru.unlocker.reports.sampler.domain.EventData;
import ru.unlocker.reports.sampler.domain.TopicEnum;

class EventDataReaderTest {

  @Test
  void testReadCsvFile() throws IOException {
    File csvFile = new File("src/test/resources/sample-event.csv");
    List<EventData> result = EventDataReader.readCsv(csvFile);
    assertNotNull(result);
    assertEquals(1, result.size());
    EventData eventData = result.get(0);
    assertNotNull(eventData);
    assertEquals(1, eventData.getTicks());
    assertEquals(TopicEnum.R, eventData.getTopic());
    assertEquals(UUID.fromString("fb62e1e0-f918-11ee-96cc-73b30c3adf76"), eventData.getReportId());
    assertEquals(UUID.fromString("fca76314-f918-11ee-b0a5-8ff348c7c462"), eventData.getGroupId());
    assertEquals("RPT01", eventData.getReportCode());
    assertEquals(Duration.ofMinutes(5), eventData.getDuration());
    assertEquals("general failure", eventData.getErrorDesc());
    assertEquals(ReportEventKind.REPORT_STARTED, eventData.getReportKind());
    assertEquals(TimerEventKind.TIMER_ENABLED, eventData.getTimerKind());

    //1,R,fb62e1e0-f918-11ee-96cc-73b30c3adf76,fca76314-f918-11ee-b0a5-8ff348c7c462,RPT01,PT5M,general failure,REPORT_STARTED,TIMER_ENABLED
  }
}